home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_073 / dissolve / blit.c next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  121 lines

  1. /* :bk=0 */
  2.  
  3. /****************************************************************************
  4.  *
  5.  *                            BLIT.C
  6.  *
  7.  ***************************************************************************/
  8.  
  9. #include "exec/types.h"
  10. #include "exec/memory.h"
  11. #include "graphics/copper.h"
  12. #include "graphics/gfx.h"
  13. #include "graphics/view.h"
  14. #include "graphics/rastport.h"
  15. #include "hardware/blit.h"
  16. #include "hardware/custom.h"
  17.  
  18. /*---------------------------------------------------------------------------
  19.  * define some stuff for blitter operations 
  20.  *--------------------------------------------------------------------------*/
  21. typedef struct
  22. {
  23.     UBYTE *blt_apt, *blt_bpt, *blt_cpt, *blt_dpt;
  24.     UWORD blt_amod, blt_bmod, blt_cmod, blt_dmod;   /* offset in bytes */
  25.  
  26.     UWORD blt_afwm, blt_alwm;             /* first and last word masks */
  27.     UWORD blt_con0;                        /* control register 0 */
  28.     UWORD blt_con1;                        /* control register 1 */
  29.  
  30.     UWORD blt_size;                        /* # of WORDS to move */
  31. } bltnode;
  32.  
  33. /* define the minterm for a blit thru a mask */
  34. /* regA is the src data, regB is the mask, regC = regD = the destination */
  35. #define COOKIE_CUT 0xc2
  36.  
  37. extern struct Custom custom;        /* define the custom chips address */
  38. struct Custom *chips = &custom;
  39.  
  40. bltnode blit;
  41.  
  42. /*---------------------------------------------------------------------------
  43.  * BlitBitMapMask() -- blit a bitmap thru a mask to another bitmap
  44.  *        both BitMap's must be the same size
  45.  *--------------------------------------------------------------------------*/
  46. BlitBitMapMask( src, dst, mask )
  47. struct BitMap *src,*dst;
  48. UBYTE *mask;
  49. {
  50.     register UBYTE **src_plane;
  51.     register UBYTE **dst_plane;
  52.     register int i;
  53.  
  54.     /* initialize the blitter control structure */
  55.     blit.blt_afwm = 0xffff;
  56.     blit.blt_alwm = 0xffff;
  57.  
  58.     blit.blt_bpt = mask;            /* reg B is the mask plane */
  59.     blit.blt_amod = 0;                /* no modulos */
  60.     blit.blt_bmod = 0;
  61.     blit.blt_cmod = 0;
  62.     blit.blt_dmod = 0;
  63.  
  64.     blit.blt_con1 = 0;                /* control register 1 */
  65.     blit.blt_con0 = DEST | SRCC |SRCB | SRCA | COOKIE_CUT;
  66.  
  67.     /* set the size register from the bit map height and width */
  68.     blit.blt_size = ( ((src->Rows & VSIZEMASK) << 6 ) | ((src->BytesPerRow >> 1) & HSIZEMASK) );
  69.  
  70.     src_plane = &src->Planes[0];
  71.     dst_plane = &dst->Planes[0];
  72.     for( i = src->Depth; i; i-- )
  73.     {
  74.         blit.blt_apt = *src_plane;
  75.         blit.blt_cpt = *dst_plane;
  76.         blit.blt_dpt = *dst_plane;
  77.         DoBlit( &blit );
  78.         src_plane++;
  79.         dst_plane++;
  80.     }
  81. }
  82.  
  83. /*---------------------------------------------------------------------------
  84.  * DoBlit() -- do one blitter operation
  85.  *--------------------------------------------------------------------------*/
  86. DoBlit( blt )
  87. register bltnode *blt;            /* the control struct for blitter operation */
  88. {
  89.     register struct Custom *cp;    /* the custom chips address */
  90.  
  91.     cp = chips;
  92.  
  93.     OwnBlitter();
  94.  
  95.     /* set the blitter data address's */
  96.     cp->bltapt   = (APTR)blt->blt_apt;
  97.     cp->bltbpt   = (APTR)blt->blt_bpt;
  98.     cp->bltcpt   = (APTR)blt->blt_cpt;
  99.     cp->bltdpt   = (APTR)blt->blt_dpt;
  100.  
  101.     /* set the blitter modulo values */
  102.     cp->bltamod  = blt->blt_amod;
  103.     cp->bltbmod  = blt->blt_bmod;
  104.     cp->bltcmod  = blt->blt_cmod;
  105.     cp->bltdmod  = blt->blt_dmod;
  106.  
  107.     /* set the first and last word mask values */
  108.     cp->bltafwm  = blt->blt_afwm;
  109.     cp->bltalwm  = blt->blt_alwm;
  110.  
  111.     /* set control registers */
  112.     cp->bltcon0  = blt->blt_con0;
  113.     cp->bltcon1  = blt->blt_con1;
  114.  
  115.     cp->bltsize  = blt->blt_size;   /* go for it !!! */
  116.  
  117.     WaitBlit();
  118.     DisownBlitter();
  119. }
  120.  
  121.